home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Full / NetObjects Fusion 9 Standard / NOF9_Full_EN.exe / data1.cab / FSI / lib / nof / Site.js < prev    next >
Encoding:
Text File  |  2005-11-16  |  8.2 KB  |  274 lines

  1. /****i* SOURCE_FILE/INFO
  2.     *
  3.     * NAME
  4.     *  Site.js
  5.     *
  6.     * USAGE
  7.     *  Part of Netobjects JavaScript Library.
  8.     *
  9.     * COPYRIGHT
  10.     *  Copyright ⌐ 2000-2005 Website Pros, Inc.
  11.     *  All Rights Reserved.
  12.     *
  13.     *  This is an unpublished work protected by Website Pros, Inc.
  14.     *  as a trade secret, and is not to be used or disclosed except as
  15.     *  expressly provided in a written license agreement executed by
  16.     *  you and Website Pros, Inc.
  17.     *
  18.     *      <copyright@websitepros.com>
  19.     *
  20.     * NOTES
  21.     *  JavaScript code.
  22.     *
  23.     *****/
  24.  
  25. if (!IS.isModuleInitialized("IS.NOF.Site"))
  26. {
  27.     /****h* NOF_JavaScript_Library/NOF.Site
  28.     *
  29.     * NAME
  30.     *  NOF.Site
  31.     *
  32.     * DESCRIPTION
  33.     *    
  34.     * External dependencies: NOF.App, NOF.UTIL.Exception
  35.     ****/
  36.     
  37.     /**
  38.     * Constructor    
  39.     */    
  40.     function NOF_Site( sitePath ) {
  41.         this.__proto__ = NOF_Site.prototype;    
  42.         //try{
  43.             //alert("|" + NOF_Site.caller + "|\r\n"); 
  44.         //if ( (NOF.Site.caller == NOF.App.getCurrentSite) || (NOF.Site.caller == NOF.App.newSite) || (NOF.Site.caller == NOF.App.openSite) ) {
  45.             this.sitePath = sitePath;
  46.         //} else {
  47.         //    throw new NOF.UTIL.Exception("invalid caller");
  48.         //}
  49.         //} catch(cexc) {
  50.         //    alert(cexc.description);
  51.         //}        
  52.     }    
  53.     {        
  54.         // declaration member variables and constants
  55.         var member = NOF_Site.prototype;    
  56.         member.CLASS_NAME            = "NOF.Site";
  57.         
  58.         // declaration member methods
  59.         var method = NOF_Site.prototype;                            
  60. /*
  61. NOF.Site( String path )
  62. boolean   isOpen()
  63. setVariable(String pName, String pValue)
  64. string  getVariable(String pName [, String altValue])
  65. String    getBaseDirectory()
  66. NOF.Page getLastOpenedPageName()
  67. Date getLastModificationDate()
  68. Date getLastPublishDate()
  69. int getNumberOfPages()
  70. NOF.Page getCurrentPage() 
  71. setCurrentPage(NOF.Page page) 
  72. loadPageById( int pageId ) 
  73. importSiteSection(NOF.Page parent, String fromPath)
  74. NOF.Page  getHomePage() //returns the home page (root node) of the opened site.
  75. save() //save the changes
  76. NOF.Layout  getLayout(String pName) // returns a named layout. This should be used for MasterBorders only because they will have unique names.
  77. getAllComponents() - in the current site
  78. getCurrentComponent()
  79. NOF.Page  createPage(String pName) // creates a new child page with the specified name (in the current site). The new page is returned.
  80. NOF.Page deletePage (String pName) // delete page
  81. */                    
  82.         
  83.         /**
  84.         * Check if the current site is open.
  85.         *
  86.         * @return true if the specified site is already open
  87.         **/
  88.         method.isOpen = function () { 
  89.             return NOF.App.getFSIApp().IsSiteOpen(this.sitePath);
  90.         }        
  91.         
  92.         /**
  93.         * Sets the value of a new or existing site specific variable. 
  94.         * Site variables are available when the current site is open.
  95.         *
  96.         * @param pName name of the variable
  97.         * @param pValue value of the variable
  98.         **/
  99.         method.setVariable = function (/*String*/ pName, /*String*/ pValue) { 
  100.             NOF.App.getFSIApp().SetSiteVar(pName, pValue);
  101.         }        
  102.         
  103.         /**
  104.         * Returns the value of a  site specific variable. If the variable is not defined 
  105.         * the function will return an empty string.
  106.         * 
  107.         * @param pName name of the variable
  108.         * @return the value of the pName variable
  109.         **/
  110.         method.getVariable = function (/*String*/ pName) { 
  111.             return NOF.App.getFSIApp().GetSiteVar(pName);
  112.         }                                    
  113.         
  114.         /**
  115.         * SetPassword defines a password that can be used within URLs
  116.         * In functions accepting a URL the password can then be specified using the string:
  117.         * %pw_<passwordName>%
  118.         * If the password name is found and the context is valid the string will be replaced by 
  119.         * the actual password.
  120.         * The password is available only in the current site.                 
  121.         * 
  122.         * @param passwordName defines a name for the password
  123.         * @param password defines the actual password. 
  124.         * @param context specifies the context for the password, which means that                          
  125.         **/
  126.         method.setPassword = function (/*String*/ passwordName,/*String*/  password,/*String*/  context) { 
  127.             NOF.App.getFSIApp2().SetSitePassword(passwordName, password, context );
  128.         }    
  129.         
  130.         /**
  131.         * HasPassword verify if a password was defined or not. 
  132.         * Passwords are defined using the function setPassword.
  133.         * @param passwordName
  134.         * @return a boolean specifying whether a password with the specified name is defined.
  135.         **/
  136.         method.hasPassword = function (/*String*/ passwordName) { 
  137.             return NOF.App.getFSIApp2().HasSitePassword(passwordName);
  138.         }                
  139.  
  140.          
  141.  
  142.         /**
  143.         * Get the base directory for the currently open Fusion site.
  144.         *
  145.         * @return the base directory path for the currently open Fusion site.
  146.         **/
  147.         method.getBaseDirectory = function () { 
  148.             return NOF.App.getFSIApp().SiteDirectory;
  149.             //return this.sitePath.substring(0, this.sitePath.lastIndexOf("\\"));
  150.         }
  151.         
  152.         /**
  153.         * Get the last opened Page (in Page view). 
  154.         *
  155.         * @return the name of the Page 
  156.         **/
  157.         method.getLastOpenedPageName = function () { 
  158.             var infoStr = this.getSiteInformation();
  159.             var tmpArr = infoStr.split(",");
  160.             var pageName = "";
  161.             for (var i = 3; i < tmpArr.length - 3; i++) {
  162.                 pageName += tmpArr[i];
  163.                 if (i < tmpArr.length - 4) pageName += ",";
  164.             }            
  165.             return pageName;
  166.         }    
  167.         
  168.         /**
  169.         * Get the date of the last modification of the site. 
  170.         *
  171.         * @return the corresponding Date object 
  172.         **/
  173.         method.getLastModificationDate = function () { 
  174.             var infoStr = this.getSiteInformation();
  175.             var tmpArr = infoStr.split(",");                        
  176.             var modifDate = new Date(tmpArr[tmpArr.length - 3] * 1000);
  177.             return modifDate;
  178.         }    
  179.         
  180.         /**
  181.         * Get the date of the last publish. 
  182.         *
  183.         * @return the corresponding Date object 
  184.         **/
  185.         method.getLastPublishDate = function () { 
  186.             var infoStr = this.getSiteInformation();
  187.             var tmpArr = infoStr.split(",");            
  188.             //var pubDateStr = "" + tmpArr[tmpArr.length - 2];                    
  189.             //var pubDate = new Date(parseInt(pubDateStr + "000"));            
  190.             var pubDate = new Date(tmpArr[tmpArr.length - 2] * 1000);            
  191.             return pubDate;
  192.         }    
  193.         
  194.         /**
  195.         * Get the number of pages in the site.
  196.         *
  197.         * @return number of pages.
  198.         **/
  199.         method.getNumberOfPages = function () { 
  200.             var infoStr = this.getSiteInformation();
  201.             return infoStr.substring(infoStr.lastIndexOf(",") + 1);
  202.         }    
  203.         
  204.         method.getSiteInformation = function () {
  205.             return NOF.App.getFSIApp2().GetSiteInformation();
  206.         }
  207.         
  208.         /**
  209.         * Get the home page in the site.
  210.         *
  211.         * @return the home page. If no site is open this function will return null.
  212.         **/
  213.         method.getHomePage = function () {             
  214.             return this.getCurrentPage().getRootPage();
  215.         }    
  216.         
  217.         /**
  218.         * Get the page currently open in the site.
  219.         *
  220.         * @return the current page. If no site is open this function will return null, otherwise the current node is always defined
  221.         **/
  222.         method.getCurrentPage = function () { 
  223.             var cPage = new NOF.Page();
  224.             cPage.fsiNode = NOF.App.getFSIApp().GetCurrentNode();
  225.             return cPage;
  226.         }    
  227.         
  228.         /**
  229.         * Defines the current page in Fusion. If this function is used in conjunction with 
  230.         * setCurrentView(1) you will open a specific page in the Page Design view. 
  231.         *
  232.         * @param currentPage the NOF.Page object to be set as current page 
  233.         **/
  234.         method.setCurrentPage = function (/*NOF.Page*/ currentPage) { 
  235.             NOF.App.getFSIApp().SetCurrentNode(currentPage.fsiNode);
  236.         }    
  237.  
  238.         /**
  239.         * Loads a page from its unique number. 
  240.         *
  241.         * @return true if the page is loaded.
  242.         **/
  243.         method.loadPageById = function (/*int*/ pageId ) {             
  244.             var node = new ActiveXObject(NOF.ProgId.FSINode);
  245.             var s = node.LoadByNumber(pageId);
  246.             node = null;
  247.             return s;
  248.         }    
  249.  
  250.         /**
  251.         * Import a new section in a site from a given location.
  252.         *
  253.         * @param parent the NOF.Page object to be set as parent page of the new section
  254.         * @param fromPath
  255.         **/
  256.         method.importSiteSection = function (/*NOF.Page*/ parent,/*String*/ fromPath) { 
  257. //TODO:        implement using FSIImporter
  258.             throw new NOF.UTIL.Exception("method not implemented!");
  259.         }    
  260.         
  261.         /**
  262.         * SetStyle sets the current style for the current site. 
  263.         * The specified style must exist in the site. 
  264.         * @param styleName the name of the local style
  265.         * @return true if the operation is successful.
  266.         **/
  267.         method.setCurrentStyle = function (/*String*/ styleName ) {
  268.             return NOF.App.getFSIApp().SetStyle(styleName);
  269.         }
  270.     }
  271.     
  272.     //NOF_Site_ProtoBuilder();
  273.     NOF.__proto__.Site = NOF_Site;
  274. }